#include <string.h>
#include <stdio.h>

void swap(char* a, char* b)
{
    char temp=*a;
    *a=*b;
    *b=temp;
}

void perm(char *str, int i)
{
    int j, len = strlen (str);
    if(i == len-1)
        printf("%s\n",str);
    else
    {
        for(j = i;j < len; j++)
        {
            swap(str+i,str+j);
            perm(str,i+1);
            swap(str+i,str+j);
        }
    }
}

int main()
{
    char str[]={"abcde"};

    perm(str,0);

    return 0;
}
//参考链接：
//http://bbs.csdn.net/topics/360025354
//http://kaqi.iteye.com/blog/13769
